package com.miyu.client1.test;

import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class lambda {
    public static void main(String[] args) {
        List a = Arrays.asList("A", "B", "C", "D", null, null, null, "H", null, "J");
        List b = Arrays.asList(null, null, null, null, "E", "F", "G", "H", null, "J", null);
        List c = Arrays.asList(null, null, null, "D", null, null, null, null, "I", "J", "K", "D");
//去重无序的
        Set<String> result1 = (Set<String>) Stream.of(a.stream(), b.stream(), c.stream()).flatMap(e -> e).
                filter(Objects::nonNull).collect(Collectors.toSet());

// 不去重的有序的
        List<String> result2 = (List<String>) Stream.of(a.stream(), b.stream(), c.stream()).flatMap(e -> e).
                filter(Objects::nonNull).collect(Collectors.toList());

//去重有序的
/*        List<String> result3 = Stream.of(a.stream(), b.stream(), c.stream()).flatMap(e -> e).
                filter(Objects::nonNull).reduce(new ArrayList<String>(), (list, value) -> {
            if (!list.contains(value)) list.add(value);
            return list;
        }, (list1, list2) -> list1);*/
        System.out.println(result1);
        System.out.println(result2);
    }


}

class  test {

    public static void main(String[] args) {
        String[] stringArray = { "Barbara", "James", "Mary", "John",
                "Patricia", "Robert", "Michael", "Linda" };
        Arrays.sort(stringArray, String::compareToIgnoreCase);
        Arrays.stream(stringArray).map(e->e).forEach(
                System.out::println
        );
    }
}
